﻿Ext.define('app.system.phase.Create',
{
    extend: 'Ext.window.Window',
    autoScroll: true,
    title: '新增阶段',
    modal: true,
    width: 600,
    height: 400,
    layout: 'fit',
    bodyStyle: 'padding:10px',
    initComponent: function () {
        var me = this;
        me.items = [me.getPhaseForm()];
        me.buttons = [
            {
                text: '保存', scope: this, handler: function () {
                    var form = me.getPhaseForm().getForm();
                    if (!form.isValid()) {
                        return false;
                    }
                    var values = me.getPhaseForm().getValues();
                    App.AjaxPost('/api/services/app/phaseInfo/CreatePhase', values, function (data) {
                        me.fireEvent("savesuccess");
                    });
                }
            },
            { text: '关闭', handler: function () { me.close(); } }
        ]
        me.callParent();
    },
    getPhaseForm: function () {
        var me = this;
        if (!this.phaseform) {
            this.phaseform = new Ext.form.Panel({
                border: false,
                defaults: {
                    anchor: '100%',
                    xtype: 'textfield',
                    labelAlign: "right"
                },
                items: [
                    {
                        fieldLabel: '阶段名称',
                        allowBlank: false,
                        name: 'name'
                    },
                    {
                        xtype: 'textarea',
                        height: 200,
                        emptyText: '逗号或分号分割',
                        fieldLabel: '阶段项',
                        name: 'detail'
                    }
                ]
            });
        }
        return this.phaseform;
    }
});